#ifndef _GLOBAL_GAME_OBJ_H_
#define _GLOBAL_GAME_OBJ_H_

#include <iostream>
#include <map>
#include <boost/property_tree/ptree.hpp>

#include "../../../../Common/PackageUtil.h"
#include "include/ModelProxy.h"
#include "include/ErrorCode.h"

using namespace std;

// big buffer size is 5 MB
#define BIG_BUF_SIZE 5120000

#define _DEBUG_LEVEL_1_

class GlobalGameObj
{
public:
	void Init(char *config_file);
	void Exit();

public:
	ModelProxy model_proxy;

	struct Common::PackageHead *p_package_head;
	struct Common::DataHead *p_data_head;
	char *p_raw_data;
	char *p_big_buf;

	Common::DataFormat format;
	int raw_data_len;
	int big_data_len;

	int package_len;

	boost::property_tree::ptree in_tree;
	// support max 3 packages
	boost::property_tree::ptree out_tree;
	boost::property_tree::ptree out_tree2;
	boost::property_tree::ptree out_tree3;
	boost::property_tree::ptree out_format_tree;
	boost::property_tree::ptree out_format_tree2;
	boost::property_tree::ptree out_format_tree3;

	boost::property_tree::ptree out_delay_tree;
	boost::property_tree::ptree out_delay_tree2;
	boost::property_tree::ptree out_delay_tree3;
	boost::property_tree::ptree out_delay_format_tree;
	boost::property_tree::ptree out_delay_format_tree2;
	boost::property_tree::ptree out_delay_format_tree3;

	unsigned int character_id;

	int error_code;
	string error_str;
};

extern map<int, GlobalGameObj *>gameObjectPool;

#endif
